package Tree;

public class item226 {
    public TreeNode invertTree(TreeNode root) {
        if(root==null) return null;
        TreeNode temp = new TreeNode();
        temp = root.left;
        root.left = root.right;
        root.right = temp;
        invertTree(root.left);
        invertTree(root.right);
    return root;
    }
    public TreeNode invertTree2(TreeNode root) {
       if(root==null) return null;
       TreeNode left =invertTree(root.left);
       TreeNode right = invertTree(root.right);
       root.left = right;
       root.right = left;
       return root;
    }
}
